import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {Category} from "../models/Category";
import 'rxjs/add/operator/map';
import {url_category as api_url } from "../config";
import {Observable} from "rxjs/Observable";

/*
 Generated class for the CategoryProvider provider.

 See https://angular.io/docs/ts/latest/guide/dependency-injection.html
 for more info on providers and Angular 2 DI.
 */
@Injectable()
export class CategoryProvider {
  public categories: Category[];

  constructor(public http: Http) {

  }

  getCategories(): Observable<Category[]> {
    return this.http.get(api_url)
      .map(response  => response.json().data as Category[] )
  }

}
